import 'package:flutter/material.dart';

class Widget_Scaffold_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Widget_Scaffold_State();
  }
}

class Widget_Scaffold_State extends State<Widget_Scaffold_Page> {
  var drawerHeader = DrawerHeader(
    padding: EdgeInsets.zero,
    child: Stack(
      children: <Widget>[
        Image.network(
            "http://img.zcool.cn/community/01f5795541d50b00000115410b205a.jpg"),
        Align(
          alignment: FractionalOffset.bottomLeft,
          child: Container(
            padding: EdgeInsets.only(left: 12.0),
            height: 70.0,
            child: Row(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                CircleAvatar(
                  backgroundImage: NetworkImage(
                      "http://img8.zol.com.cn/bbs/upload/23765/23764201.jpg"),
                ),
                Container(
                    padding: EdgeInsets.only(left: 5.0),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Text("文本1"),
                        Text("文本2"),
                      ],
                    )
                )
              ],
            ),
          ),
        )
      ],
    ),
  );

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Scaffold"),
        ),
        body: Container(
          color: Color(0xfff1f1f1),
        ),
        floatingActionButton: Builder( //当BuildContext在Scaffold之前时，调用Scaffold.of(context)会报错。这时可以通过Builder Widget来解决
            builder: (BuildContext context) {
              return FloatingActionButton(
                onPressed: () {
                  Scaffold.of(context).showSnackBar(
                      SnackBar(
                        content: Text("这是一个SnackBar"),
                        backgroundColor: Colors.red, //设置背景颜色
                        duration: Duration(
                            seconds: 10
                        ),
                        action: SnackBarAction(
                            label: "别点我",
                            onPressed: () {
                              print("SnackBar上面的按钮被点击了");
                            }
                        ),
                      )
                  );
                },
                child: Text("click"),
              );
            }),
//        bottomNavigationBar: BottomNavigationBar(items: null),
//        bottomSheet: BottomSheet(onClosing: null, builder: null),
        persistentFooterButtons: <Widget>[
          new Icon(Icons.home),
          new Icon(Icons.backspace),
          new Icon(Icons.backup),
          new Icon(Icons.arrow_back),
        ],
        drawer: Drawer(
          child: ListView(
            children: <Widget>[

              drawerHeader,

              ListTile(
                title: Text("Title1"),
                subtitle: Text("Title1  subtitle"),
                leading: CircleAvatar(
                  child: Icon(Icons.home),
                ),
                onTap: () => print("Title1"),
              ),
              ListTile(
                title: Text("Title2"),
                leading: CircleAvatar(
                  child: Icon(Icons.alarm),
                ),
                selected: true,
                trailing: Icon(Icons.add),

                onTap: () => print("Title2"),
              ),
              ListTile(
                title: Text("Title3"),
                leading: CircleAvatar(
                  child: Icon(Icons.add),
                ),
                onTap: () => print("Title3"),
                enabled: false,
              ),
            ],
          ),
        ),
        backgroundColor: Color(0xfff1f1f1),
      ),
    );
  }
}

/**
    const Scaffold({
    Key key,
    this.appBar,
    this.body,
    this.floatingActionButton,
    this.floatingActionButtonLocation,
    this.floatingActionButtonAnimator,
    this.persistentFooterButtons,//底部持久化的一些小图标
    this.drawer,
    this.endDrawer,
    this.bottomNavigationBar,
    this.bottomSheet,
    this.backgroundColor,
    this.resizeToAvoidBottomPadding = true,
    this.primary = true,//是否设置内容避开状态栏
    })
 */

